#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#define maxn 100100
typedef unsigned long long ull;
typedef long long ll;
typedef double d;
using namespace std;
struct car{
    int d;
    int v;
    int a;
    int left;
    double right;
    bool flag;
}c[maxn];
bool check(int a,double b,int c){
    if(c>=a&&c<=b)return true;
    else return false;
}
pair<int,int>check_stop[maxn];
void solve(){
    int _;
    cin>>_;
    while(_--){
        int n,m,L,V;
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            cin>>c[i].d>>c[i].v>>c[i].a;
            c[i].left=c[i].d;
            c[i].flag=false;
        }
        for(int i=1;i<=m;i++)cin>>check_stop[i].first;
        int cnt=n;
        for(int i=1;i<=n;i++){
            if(c[i].v<=V&&c[i].v<=0){
                cnt--;
                continue;
            }else{
                double csqj=0;
                csqj=1.0*(V*V-c[i].v*c[i].v)/(2*c[i].a);
                c[i].right=c[i].d+csqj;
                if(c[i].right<c[i].d)c[i].flag=true;
            }
        }
        for(int i=1,j=1;j<=n;j++){
            if(c[j].left<=check_stop[i].first&&c[j].right>=check_stop[i].first&&!c[i].flag){
                int x=i;
                for(int k=c[j].left;k<=c[j].right;k++){
                    while(!check(c[j].left,c[j].right,check_stop[x].first))x++;
                    if(check_stop[x].first==k){
                        check_stop[x].second++;
                        x++;
                    }
                }
                if(c[j+1].left>check_stop[i].first)i++;
                else if(c[j+1].left<check_stop[i].first&&i>1)i--;
                cnt--;
            }else if(c[i].flag==true){
                int l=c[i].left;
                for(int k=1;k<=m;k++){
                    if(check_stop[k].first<l)continue;
                    check_stop[k].second++;
                }
                cnt--;
            }
        }
        cout<<n-cnt<<" ";
        //cout<<"\n";
        int ans=0;
        for(int i=1;i<=m;i++){
            //cout<<check_stop[i].second<<" ";
            if(check_stop[i].second==0)ans++;
        }
        //cout<<"\n";
        cout<<ans<<" ";
        cout<<"\n";
    }
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    solve();
    fclose(stdin);
    fclose(stdout);
    return 0;
}
